﻿namespace BPM.Web.Shared.Data;

/// <summary>
/// RESTful风格
/// </summary>
/// <typeparam name="TResult"></typeparam>
public class XnRestfulResult<TResult>
{
    /// <summary>
    /// 执行成功
    /// </summary>
    public bool Success { get; set; } = false;

    /// <summary>
    /// 状态码
    /// </summary>
    public int? Code { get; set; } = 500;

    /// <summary>
    /// 错误信息
    /// </summary>
    public object? Message { get; set; }

    /// <summary>
    /// 数据
    /// </summary>
    public TResult? Data { get; set; }

    /// <summary>
    /// 附加数据
    /// </summary>
    public string? Extras { get; set; }

    /// <summary>
    /// 时间戳
    /// </summary>
    public long Timestamp { get; set; }

    /// <summary>
    /// 状态码标题
    /// </summary>
    public string GetCode() => Code.ToString() ?? "none";

    /// <summary>
    /// 状态码标题
    /// </summary>
    public string GetMessage() => Message?.ToString() ?? string.Empty;
}

